#!/bin/bash

MODULE=$1

echo "[${MODULE}]"

if [ "${MODULE}" == "" ]; then
	echo "Usage: $0 module"
	exit 1
fi

#1. 删除缓存
CMD="git rm --cached vendors/${MODULE}"
echo $CMD
eval $CMD

#2. 删除文件
CMD="rm -rf ./vendors/${MODULE}"
echo $CMD
eval $CMD

#3. 删除.gitmodules中的子模块的内容
CMD="rm -rf .git/modules/vendors/${MODULE}"
echo $CMD
eval $CMD

#4. 删除.git/config中子模块的内容
CMD="sed -i '/${MODULE}/d' .git/config"
echo $CMD
eval $CMD

#5. 删除子模块git目录
CMD="sed -i '/${MODULE}/d' .gitmodules"
echo $CMD
eval $CMD

